<div class="box">
    <div class="heading">
        <h1><img alt="" src="<?php echo base_url('assets/admin/images/setting.png'); ?>"> General Settings</h1>

        <div class="buttons">
            <a class="button" href="#" onClick="$('#settings_form').submit();"><span>Save</span></a>
        </div>
    </div>
    <div class="content">

        <?php echo form_open(null, 'id="settings_form"'); ?>
        <div class="tabs">
            <ul class="htabs">
                <li><a href="#general-tab">General</a></li>
				<li><a href="#follows-tab">Follows</a></li>
                <li><a href="#paymentgateway-tab">Payment Gateway</a></li>
            </ul>
            <!-- General Tab -->
            <div id="general-tab">
                <div class="form">
                    <div>
                        <?php echo form_label('<span class="required">*</span> Site Name:', 'sitename'); ?>
                        <?php echo form_input(array('name' => 'site_name', 'id' => 'sitename', 'value' => set_value('site_name',isset($settings['site_name']) ? $settings['site_name'] : ''))); ?>
                    </div>
					<div class="image">
						<div class="field_spacing">
							<?php echo form_label('<span class="required">*</span> Site logo:', 'sitelogo'); ?>
							<div class="attorneyimage">
								
								<img src="<?php echo base_url('assets/uploads/images').'/'.$settings['site_logo'] ;?>" alt="" id="thumb_logo" />
								<input type="hidden" name="site_logo" value="<?php echo isset($settings['site_logo']) ? $settings['site_logo'] : ''?>" id="site_logo" />
								<br />
								<a onclick="openKCFinder('site_logo','thumb_logo')">Browse</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb_logo').attr('src', ''); $('#site_logo').attr('value', '');">Clear</a>
							</div>
						</div>
					</div>
						
                    <div>
                        <?php echo form_label('<span class="required">*</span> Notification Email:', 'notification_email'); ?>
                        <?php echo form_input(array('name' => 'notification_email', 'id' => 'notification_email', 'value' => set_value('notification_email',isset($settings['notification_email']) ? $settings['notification_email'] : ''))); ?>
                    </div>
					

					 <div>
                        <?php echo form_label('<span class="required">*</span> Site Homepage:', 'site_homepage'); ?>

							<select value="" name="site_homepage" id="site_homepage">
							<?php 
								foreach($pages as $page)
								{
									if($page['pageid']==$settings['site_homepage'])
									{
										echo "<option  value='".$page['pageid']."' selected='selected'>".$page['title']."</option>";
									}
									else
									{
										echo "<option  value='".$page['pageid']."'>".$page['title']."</option>";
									}
								}								
							?>
							</select>
                    </div>
				</div>
            </div>
			<!-- Follows Tab -->
            <div id="follows-tab">
                <div class="form">
                    <div>
                        <?php echo form_label('<span class="required"></span>:Facebook Link', 'Facebook_link'); ?>
                        <?php echo form_input(array('name' => 'facebook', 'id' => 'facebook', 'value' => set_value('facebook',isset($settings['facebook']) ? $settings['facebook'] : ''))); ?>
                    </div>
                    <div>
                        <?php echo form_label('<span class="required"></span>:Twitter Link', 'Twitter_link'); ?>
                        <?php echo form_input(array('name' => 'twitter', 'id' => 'twitter', 'value' => set_value('twitter',isset($settings['twitter']) ? $settings['twitter'] : ''))); ?>
                    </div>
					<div>
                        <?php echo form_label('<span class="required"></span>:Youtube Link', 'Youtube_link'); ?>
                        <?php echo form_input(array('name' => 'youtube', 'id' => 'youtube', 'value' => set_value('youtube',isset($settings['youtube']) ? $settings['youtube'] : ''))); ?>
                    </div>
					
                </div>
            </div>
			<!-- Payment Tab -->
            <div id="paymentgateway-tab">
                <div class="form">
                    <div>
                        <?php echo form_label('<span class="required"></span>:Paypal Email', 'paypal_email'); ?>
                        <?php echo form_input(array('name' => 'paypal_email', 'id' => 'paypal_email', 'value' => set_value('paypal_email',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
                    </div>
					<div>
					
                        <?php echo form_label('<span class="required"></span>:Sandbox Mode', 'sandbox_mode'); ?>
						<input type="radio" name="sandbox_mode" value="yes" <?php if($settings['sandbox_mode']=='yes') echo 'checked="checked"'; ?> />Yes
						<input type="radio" name="sandbox_mode" value="no" <?php if($settings['sandbox_mode']=='no') echo 'checked="checked"'; ?> />No
                        
					</div>
					
                    <div>
                        <?php echo form_label('<span class="required"></span>:Business Price', 'business_price'); ?>
                        <?php echo form_input(array('name' => 'business_price', 'id' => 'business_price', 'value' => set_value('business_price',isset($settings['business_price']) ? $settings['business_price'] : ''))); ?>
                    </div>
					
                </div>
            </div>
        </div>
        <?php echo form_close(); ?>

    </div>
</div>
<style type="text/css">

#thumb_logo {
    width: 100px;
    height: 100px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
    color: #fff;
}

</style>
<script type="text/javascript">

function openKCFinder(field, thumb) {
    window.KCFinder = {
        callBack: function(url) {
            window.KCFinder = null;
            
            var img = new Image();
            img.src = url;
            img.onload = function() {
				$('#' + thumb).attr('src',url);
				
				var lastSlash = url.lastIndexOf("images/");
				
				var fileName=url.substring(lastSlash+7);
				/*var fileName = url.split('/').pop().split('\\').pop();
				alert (field);*/
				$('#' + field).attr('value',fileName);
				
            }
        }
    };
    window.open('<?php echo base_url();?>assets/admin/js/kcfinder/browse.php?type=images&dir=images',
        'kcfinder_image', 'status=0, toolbar=0, location=0, menubar=0, ' +
        'directories=0, resizable=1, scrollbars=0, width=800, height=600'
    );
}

</script>
<script type="text/javascript">
    $(document).ready(function() {
        $( ".tabs" ).tabs();
    });
</script>
